﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.tendercompanyinfo
{
    public partial class Add : Web.Admin.BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                lcs.BLL.user bu = new BLL.user();
                DataSet ds = bu.GetUserRoles(" roles_name='招标公司经理'");
                ddluser.DataSource = ds.Tables[0];
                ddluser.DataTextField = "user_name";
                ddluser.DataValueField = "user_id";
                ddluser.DataBind();
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txttcbh.Text.Trim().Length == 0)
            {
                strErr += "招标公司编号不能为空！\\n";
            }
            if (this.txttcname.Text.Trim().Length == 0)
            {
                strErr += "名称不能为空！\\n";
            }
            if (this.txttcadd.Text.Trim().Length == 0)
            {
                strErr += "地址不能为空！\\n";
            }
            if (this.txttclink.Text.Trim().Length == 0)
            {
                strErr += "联系人不能为空！\\n";
            }
                   
            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string tcbh = this.txttcbh.Text;
            string tcname = this.txttcname.Text;
            string tcadd = this.txttcadd.Text;
            string tclink = this.txttclink.Text;
            string tcphone = this.txttcphone.Text;
            string tcfax = this.txttcfax.Text;
            string tcemail = this.txttcemail.Text;
            int tcjlid = int.Parse(this.ddluser.SelectedValue);

            lcs.Model.tendercompanyinfo model = new lcs.Model.tendercompanyinfo();
            model.tcbh = tcbh;
            model.tcname = tcname;
            model.tcadd = tcadd;
            model.tclink = tclink;
            model.tcphone = tcphone;
            model.tcfax = tcfax;
            model.tcemail = tcemail;
            model.tcjlid = tcjlid;

            lcs.BLL.tendercompanyinfo bll = new lcs.BLL.tendercompanyinfo();
            bll.Add(model);
            Maticsoft.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "List.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("List.aspx");
        }
    }
}
